<?php
class Role extends AppModel {
	public $name = 'Role';

	//public $hasMany = 'GroupCategory';

	public $validate = array(
		'name' => array(
			'custom1' => array(
				'rule' => 'notEmpty',
				'message' => 'Please enter a name'
			),
			'custom2' => array(
				'rule' => 'isUnique',
				'message' => 'A role with this name already exists'
			)
		),
		'access' => array(
			'custom1' => array(
				'rule' => 'notEmpty',
				'message' => 'Please select a level of access'
			),
			'custom2' => array(
				'rule' => array('inList', array('1', '2', '3')),
				'message' => 'Please select a level of access'
			)
		),
		'id' => array(
			'rule' => 'roleExists'
		),
	);

	function roleExists($check){
		$this->id = $check['id'];
		return ($this->exists()) ? true : false;
	}
}